package com.youlai.system.controller.lichuang126;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.common.result.PageResult;
import com.youlai.system.common.result.Result;
import com.youlai.system.model.form.lichuang126.PredictedGradeForm;
import com.youlai.system.model.query.lichuang126.PredictedGradeQuery;
import com.youlai.system.model.vo.lichuang126.PredictedGradeVO;
import com.youlai.system.service.lichuang126.PredictedGradeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

@Tag(name = "126成绩预测")
@RestController
@RequestMapping("/api/predictedGrade")
@RequiredArgsConstructor
public class PredictedGradeController {
    private final PredictedGradeService predictedGradeService;

    @Operation(summary = "反馈信息分页列表", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/page")
    PageResult<PredictedGradeVO> getFeedbackPage(
            @ParameterObject PredictedGradeQuery predictedGradeQuery
    ){

        Page<PredictedGradeVO> result = predictedGradeService.getPredictedGradePage(predictedGradeQuery);

        return PageResult.success(result);
    }
    @Operation(summary = "查询", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/{id}/form")
    public Result<PredictedGradeForm> getStudentForm(
            @Parameter(description = "信息ID") @PathVariable int id
    ){
        PredictedGradeForm predictedGradeForm = predictedGradeService.getPredictedGradeFrom(id);

        return Result.success(predictedGradeForm);

    }

    @Operation(summary = "新增", security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping
    public Result savePredictedGrade(
            @RequestBody PredictedGradeForm predictedGradeForm
    ){
        boolean result = predictedGradeService.savePredictedGrade(predictedGradeForm);
        return Result.judge(result);
    }

    @Operation(summary = "修改", security = {@SecurityRequirement(name = "Authorization")})
    @PutMapping("/{id}")
    public Result updateStudent(
            @PathVariable int id,
            @RequestBody PredictedGradeForm predictedGradeForm
    ){
        boolean result = predictedGradeService.updatePredictedGrade(id, predictedGradeForm);

        return Result.judge(result);
    }

    @Operation(summary = "删除", security = {@SecurityRequirement(name = "Authorization")})
    @DeleteMapping("/{ids}")
    public Result deleteContactParents(
            @Parameter(description ="信息ID，多个以英文逗号(,)拼接") @PathVariable String ids
    ){
        boolean result = predictedGradeService.deletePredictedGrade(ids);

        return Result.judge(result);
    }
}

